﻿
$.MGJ.MutualCheck = [];

(function () {
    var _this = $.MGJ.MutualCheck;
    $.extend($.MGJ.MutualCheck, {
        conditionModel: {
            pageIndex: 1,
            pageSize: 10,
            searchKey: null,//查询条件
            type:0
        },
        Ajax_Flage: function (obj) {
            return obj == 0 ? "启用" : "禁用";
        },
        Ajax_GetMutualCheckList: function ()
        {
            var bootstrapValidator = $("#form").data('bootstrapValidator').validate();//触发全部验证
            if (bootstrapValidator.isValid()) {
                var type = $("#type").val();
                _this.conditionModel.type = type;
                _this.conditionModel.searchKey = type == "wl_Code" ? $("#WLtxt").val() : $("#FWtxt").val();
                $.L.ajaxHandle({
                    url: ACTION_URL("GetMutualCheckList", "CodeManage"),
                    data: _this.conditionModel,
                    success: function (data) {                     
                        if (data.state == 1) {
                            if (type == "wl_Code") {
                                if (data.result.PageData[0].Fw_CodeSecret != "") {
                                    $("#FWtxt").val(data.result.PageData[0].Fw_CodeSecret)
                                } else {
                                    //$.L.msgError("防伪码不存在")
                                    $("#mag").text("：该防伪码不存在").show()
                                    $("#MutualCheckTable").hide()
                                    return;
                                }
                            }                            
                            else {
                                if (data.result.PageData[0].Wl_Code != "") {
                                    $("#WLtxt").val(data.result.PageData[0].Wl_Code)
                                } else {
                                    $("#mag").text("：物流码不存在").show()
                                    $("#MutualCheckTable").hide()
                                    return;
                                }
                            }
                            $("#mag").hide();
                            $("#MutualCheckTable").L_bindingDataList(data.result.PageData);
                        }   
                        else {
                            if (type == "wl_Code") {
                                $("#mag").text("：该物流码不存在").show()
                                $("#MutualCheckTable").hide()
                            } else {
                                $("#mag").text("：该防伪码不存在").show()
                                $("#MutualCheckTable").hide()
                            }
                        }
                  
                    }
                });
            }
            else {
                $.L.msgError("请检查数据格式！");
            };
            
        }
    });
})(jQuery);

(function () {
    var _this = $.MGJ.MutualCheck;
    $.extend($.MGJ.MutualCheck, {
       
        substring_batch: function (obj) {
            
            return obj.substring(4, 8);
        },
    });
})(jQuery);

(function () {
    var _this = $.MGJ.MutualCheck;
    $.extend($.MGJ.MutualCheck, {


    });
})(jQuery);